package com.zhuiyun.pm.client.home.controller;

import com.zhuiyun.pm.client.home.pojo.ClientAnnouncement;
import com.zhuiyun.pm.client.home.service.AnnouncementService;
import com.zhuiyun.pm.page.PageRequest;
import com.zhuiyun.pm.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 用户端——公告
 * @ClassName AnnouncementController
 * @Author HH
 * @Date 2023/3/13 14:15
 **/
@RestController
@CrossOrigin
@RequestMapping("/announcement")
public class AnnouncementController {

    @Autowired
    AnnouncementService announcementService;

    /**
    * @Description 查询公告
    * @Author HH
    * @Date 2023/3/15 9:35
    * @Return com.zhuiyun.pm.result.CommonResult
    * @param pageRequest
    */
    @GetMapping("/selectAnnouncementList")
    public CommonResult selectAnnouncementList(String address, PageRequest pageRequest){
        return announcementService.selectAnnouncementList(address, pageRequest);
    }

    /**
    * @Description 公告浏览量自增
    * @Author HH
    * @Date 2023/3/15 21:24
    * @Return com.zhuiyun.pm.result.CommonResult
    * @param clientAnnouncement
    */
    @PostMapping("/announcementPageViewsIncr")
    public CommonResult announcementPageViewsIncr(@RequestBody ClientAnnouncement clientAnnouncement){
        return announcementService.announcementPageViewsIncr(clientAnnouncement);
    }

    /**
    * @Description 根据token查询用户信息
    * @Author HH
    * @Date 2023/3/19 20:48
    * @Return com.zhuiyun.pm.result.CommonResult
    * @param token
    */
    
    @GetMapping("/getUserInfoByToken")
    public CommonResult getUserInfoByToken(String token){
        return announcementService.getUserInfoByToken(token);
    }
}
